﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.EquipmentManagement;

namespace Digitalmes.Model.EquipmentManagement
{
    /// <summary>
    /// 维护计划
    /// </summary>
	[Table("MaintenancePlan")]

    [Display(Name = "_Model.MaintenancePlan")]
    public class MaintenancePlan : BasePoco,IPersistPoco,ITenant
    {
        [Key]
        [Display(Name = "_Model._MaintenancePlan._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._MaintenancePlan._PlanName")]
        [Comment("计划名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string PlanName { get; set; }
        [Display(Name = "_Model._MaintenancePlan._Equipment")]
        [Comment("关联设备")]
        public Equipment Equipment { get; set; }
        [Display(Name = "_Model._MaintenancePlan._Equipment")]
        [Comment("关联设备")]
        public long? EquipmentId { get; set; }
        [Display(Name = "_Model._MaintenancePlan._EquipmentName")]
        [Comment("关联设备")]
        [NotMapped]
        public string EquipmentName { get; set; }
        [Display(Name = "_Model._MaintenancePlan._PlanType")]
        [Comment("计划类型")]
        public MaintenanceTypeEnum? PlanType { get; set; }
        [Display(Name = "_Model._MaintenancePlan._IntervalDays")]
        [Comment("周期(天）")]
        public int? IntervalDays { get; set; }
        [Display(Name = "_Model._MaintenancePlan._NextDueDate")]
        [Comment("下次执行日期")]
        public DateTime? NextDueDate { get; set; }
        [Display(Name = "_Model._MaintenancePlan._IsActive")]
        [Comment("是否启用")]
        public bool? IsActive { get; set; }
        [Display(Name = "_Model._MaintenanceRecord._Plan")]
        [InverseProperty("Plan")]
        public List<MaintenanceRecord> MaintenanceRecord_Plan { get; set; }
        [Display(Name = "_Model._MaintenancePlan._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
